Skip to content

Fixing bug with enums as eventHeaders#4337

Merged
landonxjames merged 5 commits intomainfrom
landonxjames/eventheader-enum
Oct 13, 2025
Merged

Fixing bug with enums as eventHeaders#4337
landonxjames merged 5 commits intomainfrom
landonxjames/eventheader-enum

Conversation

@landonxjames
Copy link
Contributor

@landonxjames landonxjames commented Oct 8, 2025

Motivation and Context

Fixing a bug that was discovered with smithy enum and intEnum shapes that are marked as @eventHeader. This came up in an internal investigation around a failed preview build.

Description

Added handling of EnumShape in EventStreamUnmarshallerGenerator and EventStreamMarshallerGenerator.

Testing

Added new enum and intEnum shapes to the evenstream test model. They are only included in client tests since the server throws a validation error on enums in event streams (see smithy-lang/smithy#1388 for more info).

Also tested against the model from the failed preview build and a cargo test --all-features was successful.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@landonxjames landonxjames marked this pull request as ready for review October 9, 2025 05:40
@landonxjames landonxjames requested review from a team as code owners October 9, 2025 05:40
@github-actions
Copy link

github-actions bot commented Oct 9, 2025

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

BAR
}

intEnum FaceCard {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we support intEnum yet? #1700

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but I still think this should stay in the test so that when we do support them we get an obvious test failure if they don't work as @eventHeaders instead of a false positive.

is IntegerShape -> rustTemplate("#{expect_fns}::expect_int32(header)?", *codegenScope)
is LongShape -> rustTemplate("#{expect_fns}::expect_int64(header)?", *codegenScope)
is BlobShape -> rustTemplate("#{expect_fns}::expect_byte_array(header)?", *codegenScope)
is EnumShape -> rustTemplate("#{expect_fns}::expect_string(header)?.as_str().into()", *codegenScope)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this handle intEnum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any codegen actually supports intEnum (see #1700) so it isn't handled here. I did add it to the test model though so when we do support it we will get an obvious error in these tests if it doesn't work as an @eventHeader.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@landonxjames landonxjames enabled auto-merge (squash) October 13, 2025 20:09
@landonxjames landonxjames merged commit 84382a3 into main Oct 13, 2025
50 checks passed
@landonxjames landonxjames deleted the landonxjames/eventheader-enum branch October 13, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants